home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / vsrc.tar / voyager7_src / ports.c < prev    next >
C/C++ Source or Header  |  1991-02-27  |  2KB  |  113 lines

  1. /*
  2. // Abstract:
  3. //    PORTS---Ports
  4. //
  5. //    The Ports module provides access to the various port based
  6. //    routiens.
  7. //
  8. // Author:
  9. //    Derek S. Nickel
  10. //
  11. // Creation date:
  12. //    8 January 1991
  13. //
  14. // History:
  15. // V01-001    Derek S. Nickel         8-JAN-1991
  16. //    Original.
  17. //
  18. */
  19.  
  20. #include <ctype.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <io.h>
  24. #include <time.h>
  25.  
  26. #include "memory.h"
  27. #include "index.h"
  28. #include "modes.h"
  29. #include "ports.h"
  30.  
  31. /***********************************************************************
  32.     close_port
  33. ***********************************************************************/
  34.  
  35. void close_port(int port_no)
  36. {
  37.     if (ports[port_no].loaded) {
  38.         close_memory_file(ports[port_no].mem_file);
  39.         close_text_file(ports[port_no].ca_file);
  40.         close_text_file(ports[port_no].cc_file);
  41.         ports[port_no].module[0] = '\0';
  42.         ports[port_no].loaded = 0;
  43.     }
  44. }
  45.  
  46. /***********************************************************************
  47.     merge_port
  48. ***********************************************************************/
  49.  
  50. void merge_port(int port_no, char *module)
  51. {
  52.     if (ports[port_no].loaded) {
  53.         char xmodule[_MAX_PATH];
  54.  
  55.         _fullpath(xmodule, module, _MAX_PATH);
  56.  
  57.         merge_text_file(
  58.             ports[port_no].ca_file,
  59.             xmodule,
  60.             "CA");
  61.  
  62.         /* dont merge code comments
  63.         merge_text_file(
  64.             ports[port_no].cc_file,
  65.             xmodule,
  66.             "CC");
  67.         */
  68.     }
  69. }
  70.  
  71. /***********************************************************************
  72.     open_port
  73. ***********************************************************************/
  74.  
  75. void open_port(int port_no, char *module)
  76. {
  77.     close_port(port_no);
  78.     _fullpath(ports[port_no].module, module, _MAX_PATH);
  79.     open_memory_file(&ports[port_no].mem_file, ports[port_no].module);
  80.     open_text_file(ports[port_no].ca_file, ports[port_no].module, "CA");
  81.     open_text_file(ports[port_no].cc_file, ports[port_no].module, "CC");
  82.     ports[port_no].loaded = 1;
  83. }
  84.  
  85. /***********************************************************************
  86.     sort_port
  87. ***********************************************************************/
  88.  
  89. void sort_port(int port_no)
  90. {
  91.     if (ports[port_no].loaded) {
  92.         int idx = 1;
  93.         time_t ctime;
  94.         char cur_time[9];
  95.  
  96.         sprintf(cur_time, "TMP%05lX", 0xFFFFF & time(&ctime));
  97.  
  98.         sort_text_file(
  99.             ports[port_no].ca_file,
  100.             ports[port_no].module,
  101.             "CA",
  102.             cur_time,
  103.             &idx );
  104.  
  105.         sort_text_file(
  106.             ports[port_no].cc_file,
  107.             ports[port_no].module,
  108.             "CC",
  109.             cur_time,
  110.             &idx );
  111.     }
  112. }
  113.